# -*- coding: utf-8 -*-
"""
@author: wyb
@date: 2024/1/12
@time: 21:14
@desc: 自动爬取萝卜投研的财报，分析得出股票估算价格
"""

import fetchService as ft
import roboService as robo
import os


def main():
    # region 雪球选股API测试
    # condition = '&indcode=S3705&order_by=symbol&order=desc&page=1&size=30&only_count=0&current=&pct=&pettm=1_50&mc=5000000000_&_=1705065082063'
    # lis = ft.getstocklist(condition)
    # print(lis)
    # endregion

    # region 萝卜投研 API 测试
    url = "https://robo.datayes.com/"
    username = "13697762249"
    pwd = 'XY@1234@abcd'
    session = robo.loginrobo(url, username, pwd)
    # stocks = robo.choseStocks(session)
    # robo.writeStockToCSV(stocks, 'stocks.csv')

    # 股票列表
    lis = ['000895', '600036', '603288']
    subdir = mksubdir('stock_reports')
    robo.downFinanceReport(session, lis, subdir)
    # endregion


def mksubdir(directory_name):
    # 获取当前工作目录
    current_directory = os.getcwd()

    # 构建子目录的完整路径
    new_directory_path = os.path.join(current_directory, directory_name)
    if not os.path.exists(new_directory_path):
        os.mkdir(new_directory_path)  # 创建子目录
    return new_directory_path


if __name__ == '__main__':
    main()
